package com.beetle123.model;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * @author yuanlong.chen
 * @date 2021/09/07
 */
public class ProjectModel {
    private String appName;
    private String env;
    private List<String> ipPortList = new ArrayList<>(16);
    private LinkedHashMap<String, ServiceModel> serviceMap = new LinkedHashMap<>(16);

    public ProjectModel(String env, String appName) {
        this.appName = appName;
        this.env = env;
    }

    public String getEnv() {
        return env;
    }

    public void setEnv(String env) {
        this.env = env;
    }

    public List<String> getIpPortList() {
        return ipPortList;
    }

    public void setIpPortList(List<String> ipPortList) {
        this.ipPortList = ipPortList;
    }

    public LinkedHashMap<String, ServiceModel> getServiceMap() {
        return serviceMap;
    }

    public void setServiceMap(LinkedHashMap<String, ServiceModel> serviceMap) {
        this.serviceMap = serviceMap;
    }

    public void addService(String key, ServiceModel service) {
        this.serviceMap.putIfAbsent(key, service);
    }

    public void addIpPort(String ipPort) {
        if (this.ipPortList.contains(ipPort)) {
            return;
        }
        this.ipPortList.add(ipPort);
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }
}
